#ifndef DB_H
#define DB_H

#include "qtlibs.h"
#include "entities/room.h"
#include "entities/user.h"

// class is singleton
class DB {
public:
    static DB* getInstance();
    bool connect(QString host, QString user, QString pass, QString dbname);
    bool execute(QString query);
    QList<QString>* select(QString query);
    ~DB();

    QList<User*> getUsers();
    void addUser(User* user);
    void addRoom(Room* room);
    User* findByLogin(QString login);
    User* findByIdentify(QString identify);
    Room* findRoom(QString roomName);

    QList<Room*> getRooms();

protected:
    DB();

private:
    static DB* instance;
    // connection* connection;

    QList<User*> users;
    QList<Room*> rooms;
};

#endif // DB_H
